<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            background-color: pink;
            width: 100px;
            height: 100px;
        }
    </style>
</head>
<body>
    <div>111</div>
    <div>222</div>
    <div>333</div>
    <script>
        var divs = document.querySelectorAll('div');
        divs[0].onclick = function(){
            alert('111');
            divs[0].onclick = null;
        }

        divs[1].addEventListener('click',fn)
        function fn(){
            alert('2222');
            divs[1].removeEventListener('click',fn);//移除点击事件 和这个函数
        }
    </script>
</body>
</html>